//
//  LJCMusicTableViewCell.m
//  WZLProduct
//
//  Created by 陆静聪 on 16/3/18.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "LJCMusicTableViewCell.h"

@interface LJCMusicTableViewCell ()

@property (nonatomic, retain) UIImageView *blackPic;/**< 图片 */
@property (nonatomic, retain) UILabel *detailLabel;/**< 描述 */
@property (nonatomic, retain) UIImageView *listenPic;/**< 听众图片 */
@property (nonatomic, retain) UIImageView *likePic;/**< 喜欢图片 */
@property (nonatomic, retain) UILabel *listenlabel;/**< 听众数 */
@property (nonatomic, retain) UILabel *likelabel;/**< 喜欢数 */
@property (nonatomic, retain) UIImageView *morePic;/**< more */

@end

@implementation LJCMusicTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createCell];
        
    }
    return self;
}
/** 赋值 */
- (void)setCategoryModel:(LJCMusicModel *)categoryModel {
    if (_categoryModel != categoryModel) {
        _categoryModel = categoryModel;
        [self giveData];
    }
}

- (void)giveData {
    [_blackPic sd_setImageWithURL:[NSURL URLWithString:_categoryModel.imgUrl] placeholderImage:kStanceImage];
    _detailLabel.text = _categoryModel.title;
    _listenlabel.text = [NSString stringWithFormat:@"%.1lfk", _categoryModel.plays / 1000];
    _likelabel.text = [NSString stringWithFormat:@"%ld", _categoryModel.likes];
}

/** 创建Cell */
- (void)createCell {
    _blackPic = [[UIImageView alloc] init];
    [self.contentView addSubview:_blackPic];
    [_blackPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.offset(0);
        make.width.equalTo(_blackPic.mas_height);
    }];
    _blackPic.backgroundColor = [UIColor clearColor];
    
    _detailLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_detailLabel];
    [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_blackPic.mas_right).offset(5);
        make.centerY.equalTo(_blackPic.mas_centerY);
        make.right.offset(-60);
        make.height.mas_equalTo(25);
    }];
    _detailLabel.backgroundColor = [UIColor clearColor];
    
    _listenPic = [[UIImageView alloc] init];
    [self.contentView addSubview:_listenPic];
    [_listenPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_blackPic.mas_right).offset(5);
        make.top.equalTo(_detailLabel.mas_bottom).offset(5);
        make.size.mas_equalTo(CGSizeMake(18, 18));
    }];
    _listenPic.backgroundColor = [UIColor clearColor];
    
    _listenlabel = [[UILabel alloc] init];
    [self.contentView addSubview:_listenlabel];
    [_listenlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_listenPic.mas_right).offset(5);
        make.centerY.equalTo(_listenPic.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(25, 18));
    }];
    _listenlabel.backgroundColor = [UIColor clearColor];
    _listenlabel.font = FONT12;
    
    
    _likePic = [[UIImageView alloc] init];
    [self.contentView addSubview:_likePic];
    [_likePic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_listenPic.mas_centerY);
        make.left.equalTo(_listenlabel.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(18, 18));
    }];
    _likePic.backgroundColor = [UIColor clearColor];
    
    _likelabel = [[UILabel alloc] init];
    [self.contentView addSubview:_likelabel];
    [_likelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_listenPic.mas_centerY);
        make.left.equalTo(_likePic.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(25, 18));
    }];
    _likelabel.backgroundColor = [UIColor clearColor];
    _likelabel.font = FONT12;
    
    _morePic = [[UIImageView alloc] init];
    [self.contentView addSubview:_morePic];
    [_morePic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_detailLabel.mas_centerY);
        make.left.equalTo(_detailLabel.mas_right).offset(25);
        make.width.mas_equalTo(15);
        make.height.mas_equalTo(15);
    }];
    _morePic.image = [UIImage imageNamed:@"iconfont-shenglve.png"];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
